import request from '@/utils/request'
var group_name = 'comment'
export default {
  save(comment) { // 添加
    return request({
      url: `/${group_name}/save`,
      method: 'post',
      data: comment
    })
  },
  commentGoods(commentGoods) { // 点赞
    return request({
      url: `/${group_name}/commentGoods`,
      method: 'put',
      data: commentGoods
    })
  },
  getListByBlogId(comment, sort) { // 获取博客的评论
    return request({
      url: `/${group_name}/getListByBlogId?blogId=${comment}&sort=${sort}`,
      method: 'get'
    })
  },
  getByPage(page) { // 分页查询
    return request({
      url: `/${group_name}/getByPage`,
      method: 'post',
      data: page
    })
  },
  getReplyByParentId(id) { // 获取一条评论的子评论
    return request({
      url: `/${group_name}/getReplyByParentId/${id}`,
      method: 'get'
    })
  },
  reply(formData) { // 评论回复
    return request({
      url: `/${group_name}/reply`,
      method: 'post',
      data: formData,
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    })
  },
  getCommentsSum(blogId) {
    return request({
      url: `/${group_name}/getCommentsSum/${blogId}`,
      method: 'get'
    })
  }
}
